home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / include / pgm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-12  |  1.8 KB  |  57 lines

  1. /* pgm.h - header file for libpgm portable graymap library
  2. */
  3.  
  4. #ifndef _PGM_H_
  5. #define _PGM_H_
  6.  
  7.  
  8. #include "pbm.h"
  9.  
  10. #ifdef PGM_BIGGRAYS
  11. typedef unsigned short gray;
  12. #define PGM_MAXMAXVAL 65535
  13. #else /*PGM_BIGGRAYS*/
  14. typedef unsigned char gray;
  15. #define PGM_MAXMAXVAL 255
  16. #endif /*PGM_BIGGRAYS*/
  17.  
  18.  
  19. /* Magic constants. */
  20.  
  21. #define PGM_MAGIC1 'P'
  22. #define PGM_MAGIC2 '2'
  23. #define RPGM_MAGIC2 '5'
  24. #define PGM_FORMAT (PGM_MAGIC1 * 256 + PGM_MAGIC2)
  25. #define RPGM_FORMAT (PGM_MAGIC1 * 256 + RPGM_MAGIC2)
  26. #define PGM_TYPE PGM_FORMAT
  27.  
  28.  
  29. /* Macro for turning a format number into a type number. */
  30.  
  31. #define PGM_FORMAT_TYPE(f) ((f) == PGM_FORMAT || (f) == RPGM_FORMAT ? PGM_TYPE : PBM_FORMAT_TYPE(f))
  32.  
  33.  
  34. /* Declarations of routines. */
  35.  
  36. void pgm_init ARGS(( int* argcP, char* argv[] ));
  37.  
  38. #define pgm_allocarray( cols, rows ) ((gray**) pm_allocarray( cols, rows, sizeof(gray) ))
  39. #define pgm_allocrow( cols ) ((gray*) nzalloc( cols, sizeof(gray), "pgm-row"))
  40. #define pgm_freearray( grays, rows ) pm_freearray( (char**) grays, rows )
  41. #define pgm_freerow( grayrow ) pm_freerow( (char*) grayrow )
  42.  
  43. gray** pgm_readpgm ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP ));
  44. int pgm_readpgminit ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP, int* formatP ));
  45. int pgm_readpgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int format ));
  46.  
  47. void pgm_writepgm ARGS(( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain ));
  48. void pgm_writepgminit ARGS(( FILE* file, int cols, int rows, gray maxval, int forceplain ));
  49. void pgm_writepgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain ));
  50.  
  51. extern gray pgm_pbmmaxval;
  52. /* This is the maxval used when a PGM program reads a PBM file.  Normally
  53. ** it is 1; however, for some programs, a larger value gives better results
  54. */
  55.  
  56. #endif /*_PGM_H_*/
  57.